package cn.wlinker.video.monitor.brand.hikversion.enums;

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.wlinker.video.monitor.brand.hikversion.utils.EZOpenRequestUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Map;
import java.util.Optional;

/**
 * ezOpen请求地址枚举
 *
 * @author gxsjx
 * @version 1.0
 * @date 2022/11/11
 */
@AllArgsConstructor
public enum EZOpenRequestEnum {
    GET_TOKEN("/token/get", "获取token"),
    CLOSE_LIVE("/live/video/close", "关闭加密直播"),
    GET_STREAM("/v2/live/address/get", "获取视频流"),
    DEVICE_LIST("/device/list", "获取设备列表"),
    PTZ_START("/device/ptz/start", "开始云台控制"),
    PTZ_STOP("/device/ptz/stop", "停止云台控制"),
    CAPTURE("/device/capture", "图片抓拍"),
    PRESET_ADD("/device/preset/add", "添加预置点"),
    PRESET_MOVE("/device/preset/move", "调用预置点"),
    PRESET_CLEAR("/device/preset/clear", "清除预置点"),
    CAPACITY("/device/capacity", "根据设备序列号查询设备能力集"),
    ;

    private final String url;

    @Getter
    private final String name;

    private final static String host = "https://open.ys7.com/api/lapp";

    public String getUrl() {
        return StrUtil.format("{}{}", host, url);
    }

    /**
     * 发送http请求
     *
     * @param params
     * @return
     */
    public Optional<JSONObject> requestAndGetData(Map<String, Object> params) {
        return EZOpenRequestUtils.requestAndGetData(getUrl(),params);
    }

    /**
     * 发送http请求
     *
     * @param params
     * @return
     */
    public  Optional<JSONObject> requestAndGetAll(Map<String, Object> params) {
        return EZOpenRequestUtils.requestAndGetAll(getUrl(),params);
    }
}
